﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.Architecture.Data;
using HF.BaseWebCtrlLib;
using HF.Framework;
using HF.WorkFlow.Const;

public partial class BasePages_AccreditPage_SelectUsers : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!this.IsPostBack)
        {
            BaseUserPage.LoadWaitPage();
            LoadArchitecture(WorkFlowConst.Architecture_Department, tvArch.Nodes);
        }
    }
    /// <summary>
    /// 递归装载全部组织结构
    /// </summary>
    /// <param name="key"></param>
    /// <param name="startNodes"></param>
    private void LoadArchitecture(string key, TreeNodeCollection startNodes)
    {
        try
        {
            if (key == null || key == "") key = "0";
            DataTable table = ArchitectureData.GetInstance().GetArchitectureTable(key);
            foreach (DataRow row in table.Rows)
            {

                TreeNode tmpNode = new TreeNode();
                tmpNode.Value = row["ArchitectureId"].ToString();
                tmpNode.Text = row["Caption"].ToString();
                tmpNode.Target = "usersfrm";
                tmpNode.NavigateUrl = "Userfrm.aspx?keyType=" + WorkFlowConst.Architecture_Department+"&keyValue="+tmpNode.Value+"";
                if (row["TypeName"].ToString() == WorkFlowConst.Architecture_Department)
                {
                    tmpNode.ImageUrl = @"..\..\Resources\image\folder.bmp";

                }
                else
                    if (row["TypeName"].ToString() == WorkFlowConst.Architecture_Duty)
                    {
                        tmpNode.ImageUrl = @"..\..\Resources\image\duty.bmp";
                    }
                startNodes.Add(tmpNode);
                LoadArchitecture(tmpNode.Value, tmpNode.ChildNodes);

            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}
